#include <QtTest>
#include <QCoreApplication>

// add necessary includes here
#include <QProcess>

class ProcessTest : public QObject
{
    Q_OBJECT

public:
    ProcessTest();
    ~ProcessTest();

public slots:
    void onBytesWritten(qint64 i);
    void onChannelReadyRead(int i);
    void onReadyRead();
    void onReadyReadStandardOutput();

private slots:
    void initTestCase();
    void cleanupTestCase();
    void test_case1();

private:
    QProcess m_process;
};

void ProcessTest::onBytesWritten(qint64 i)
{
    qDebug("%s(%s)[%d] %lld", __FILE__, __func__, __LINE__, i);
}

void ProcessTest::onChannelReadyRead(int i)
{
    qDebug("%s(%s)[%d] %d", __FILE__, __func__, __LINE__, i);
}

void ProcessTest::onReadyRead()
{
    qDebug("%s(%s)[%d] %s", __FILE__, __func__, __LINE__, m_process.readAll().data());
}

void ProcessTest::onReadyReadStandardOutput()
{
    qDebug("%s(%s)[%d]", __FILE__, __func__, __LINE__);
}

ProcessTest::ProcessTest()
{

}

ProcessTest::~ProcessTest()
{

}

void ProcessTest::initTestCase()
{
    connect(&m_process, SIGNAL(bytesWritten(qint64)), SLOT(onBytesWritten(qint64)));
    connect(&m_process, SIGNAL(channelReadyRead(int)), SLOT(onChannelReadyRead(int)));
    connect(&m_process, SIGNAL(readyRead()),  SLOT(onReadyRead()));
    connect(&m_process, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput()));
    m_process.start("/tmp/test.sh");

    qApp->exec();
}

void ProcessTest::cleanupTestCase()
{

}

void ProcessTest::test_case1()
{

}

QTEST_MAIN(ProcessTest)

#include "tst_processtest.moc"
